import json

path = "../resources/json/chart_stats.json"
new_file_path = "../resources/json/chart_stats_filter.json"

unicode_data = dict()
filter_data = dict()

with open(path, "r", encoding="utf-8") as file:
    loaded_data = json.load(file)
    charts_data = loaded_data.get("charts", {})
    unicode_data.update(charts_data)

for key, value in unicode_data.items():
    fit_diff_exp = value[2].get("fit_diff", 0)
    fit_diff_mas = value[3].get("fit_diff", 0)
    fit_diff_rem = value[4].get("fit_diff", 0)
    data = {
        "exp": fit_diff_exp,
        "mas": fit_diff_mas,
        "rem": fit_diff_rem
    }
    filter_data[key] = data

with open(new_file_path, "w", encoding="utf-8") as file:
    json.dump(filter_data, file, indent=4)

print("完成!")
